<template>
  <div class="sm-card" :class="'sm-card-shadow-'+shadow">
    <div class="sm-card-header" v-if="$slots.header || header">
      <slot name="header"></slot>
    </div>
    <div class="sm-card-default">
      <slot name="default"></slot>
    </div>
    <div class="sm-card-footer" v-if="$slots.footer || footer">
      <slot name="footer"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "SmCard",
  props: {
    header: {},
    footer: {},
    shadow: {
      type: String,
      default: "hover"
    }
  }
};
</script>

<style>
.sm-card {
  width: 150px;
  height: 100px;
  display: inline-block;
  vertical-align: top;
  /* padding: 0px 10px 0px 10px; */
  /* margin: 10px; */
  border: 1px solid #dadada;
  /* border-radius: 10px; */
}
/* 总是显示阴影 */
.sm-card-shadow-always {
  box-shadow: 0 9px 30px -6px rgba(0, 0, 0, 0.2),
    0 18px 20px -10px rgba(0, 0, 0, 0.04), 0 18px 20px -10px rgba(0, 0, 0, 0.04),
    0 10px 20px -10px rgba(0, 0, 0, 0.04);
}

/* 鼠标悬浮时显示阴影 */
.sm-card-shadow-hover {
  -webkit-transition: 0.3s;
  transition: 0.3s;
}
.sm-card-shadow-hover:focus,
.sm-card-shadow-hover:hover {
  box-shadow: 0 9px 30px -6px rgba(0, 0, 0, 0.2),
    0 18px 20px -10px rgba(0, 0, 0, 0.04), 0 18px 20px -10px rgba(0, 0, 0, 0.04),
    0 10px 20px -10px rgba(0, 0, 0, 0.04);
}

/* 从不显示阴影 */
.sm-card-shadow-never {
  box-shadow: none;
}

.sm-card-header {
  overflow: hidden;
  position: relative;
  width: 100%;
  /* height: 40px; */
  /* line-height: 40px; */
  /* text-align: center; */
  display: block;
  /* border-bottom: 1px solid #dedede; */
}
.sm-card-default {
  width: 100%;
  /* padding: 10px 0px; */
  /* text-align: center; */
}
.sm-card-footer {
  overflow: hidden;
  position: relative;
  width: 100%;
  display: block;
}
</style>
